// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MockStep.cs" company="">
//   
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Tests
{
    using System;

    using ExecutionTool.Common;
    using ExecutionTool.Profile;

    using Microsoft.Practices.EnterpriseLibrary.Logging;

    using Moq;

    public class MockStep : StepBase<int>
    {
        #region Constructors and Destructors

        public MockStep()
            : this(null)
        {
        }

        public MockStep(double? interval)
            : base(new Profile(), true, (new Mock<LogWriter>()).Object, interval)
        {
            this.StartActionFactory = () => 0;
            this.ProgressHeartbeatActionFactory = () => 0;
            this.AbortActionFactory = () => { };
        }

        #endregion

        #region Public Properties

        public Action AbortActionFactory { get; set; }

        public Func<bool> IsAbortableFactory
        {
            set
            {
                this.CanAbort = value();
            }
        }

        public Func<double> ProgressHeartbeatActionFactory { get; set; }

        public Func<int> StartActionFactory { get; set; }

        #endregion

        #region Methods

        protected override void AbortAction()
        {
            this.AbortActionFactory();
        }

        protected override void CleanupAction()
        {
        }

        protected override double ProgressHeartbeatAction()
        {
            return this.ProgressHeartbeatActionFactory();
        }

        protected override int StartAction()
        {
            return this.StartActionFactory();
        }

        #endregion
    }
}
